﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Configuration;
using Company.StudyClub.Model;

namespace Company.StudyClub.BLL.Common
{
    public class HttpHelper
    {
        public HttpHelper()
        {
        }

        private User_Info currentUser = new User_Info();
        public User_Info CurrentUser
        {
            get
            {
                if (currentUser.UserID == 0)
                {
                    try
                    {
                        string seUser = Cookie.CookieManager.ReadCookie(User.UserConst.COOKIE_SERIALIZE_NAME).Trim();
                        try
                        {
                            User.UserBLL objBLL = new User.UserBLL();

                            currentUser = objBLL.DeSerialUser(seUser);
                        }
                        catch { }
                    }
                    catch { }
                }
                return currentUser;
            }
        }

        public string GetString(string name)
        {
            string rtvl = "";
            try
            {
                rtvl = Utility.CheckParameter(HttpContext.Current.Request[name].ToString().Trim());
            }
            catch { }
            return rtvl;
        }

        public int GetInt(string name)
        {
            int id = 0;
            try
            {
                id = Int32.Parse(HttpContext.Current.Request[name].ToString().Trim());
            }
            catch { }
            return id;
        }
    }
}
